Java Programming Find Max

This programming assignment is designed to evaluate your knowledge, comprehension and application of some Java programming constructs - variable declaration, expressions, conditionals and the provided do loop. It is expected that a program can be written that compiles and runs correctly. You should work on this programming assignment on your own. However, collaboration with others on general logic flow, techniques and Java Core API methods available may be useful. It is most beneficial if you do not share code.

Program: Write a Java program that accepts input from the keyboard, you can assume the input is valid signed integers, and display on the screen the count of the number entered followed by a period (.), the value of the number entered and the maximum number entered so far in accordance with the sample below. The prompt for input should be "Enter an integer number: ".

Sample screen output during a particular running of the program:

Enter an integer number: 27

1. The number is 27, the maximum value so far is 27.

Enter an integer number: -3

2. The number is –3, the maximum value so far is 27.

Enter an integer number: 946

3. The number is 946, the maximum value so far is 946.

etc…

Once no value is entered from the keyboard (just the enter key) exit the program.

The name of the object must be Ex1. To run the program, the Ex1 Java object is invoked. The Ex1 skeleton source code is presented below and should be used. This source code should be put in a file named Ex1.java and then compiled. When it is compiled the object that is run will be called Ex1.class. The entire program can be implemented in the main method.

IMPORTANT: The file for this program must be named Ex1.java. (Not EX01, ex1, or any other variation). Your file must be should placed in a subdirectory for this project. I suggest something like C:\javacode\Ex1\

 

Ex1.java code:

import java.io.*;
           
public class Ex1
{
              
  Ex1()
  {
  }
             
  public static void main(String args[])
  {
   BufferedReader console;
   console = new BufferedReader(new InputStreamReader(System.in));
      
   String intstring = "";
   int intnum = 0;

//declare other variables here

   do
   {
    try
    {
     System.out.print("prompt");
     intstring = console.readLine();
    }
    catch (IOException e)
    {
     //ignore exception
    }
         
    if (intstring.equals(""))
    {
     break;
    }
         
    try
    {
     intnum = Integer.parseInt(intstring);
    }
    catch (NumberFormatException e)
    {
     System.out.println("ERROR: "+e.getMessage());
    }

//insert logic here        

   } while (true);
     
  } //end main
   
} //end of Ex1 class